#ifndef MSG_H
#define MSG_H

#include <pthread.h>

#include "core_conf.h"

extern struct core_conf core_conf;

struct msg {
	char from[64]; /* from which task */
	char to[64]; /* to which task */
	int ops; /* what this msg means */
	unsigned int is_request; /* 1:this a request msg, 0: this a result msg */

	void *data;

	struct msg *next;
};

struct msg_queue {
	struct msg *head;
	int count;
	pthread_mutex_t lock;
};

extern struct msg_queue *msg_queue_create(void);
extern int send_msg(struct msg *msg);
extern int receive_msg(struct msg **msg);
extern int get_request_msg(struct msg **msg, char *task_name);

#endif
